package com.zoweunion.mechanic.service.app.impl;

import cn.jpush.api.push.PushResult;
import com.zoweunion.mechanic.dao.app.PushMessageRecordMapper;
import com.zoweunion.mechanic.plugins.jpush.JiguangPush;
import com.zoweunion.mechanic.service.app.PushMessageRecordService;
import com.zoweunion.mechanic.util.UuidUtil;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class PushMessageRecordServiceImpl implements PushMessageRecordService {

    @Autowired
    private JiguangPush jiguangPush;

    @Autowired
    private PushMessageRecordMapper pushMessageRecordMapper;

    @Override
    public boolean insertMessageRecord(Map<String, Object> map) {
        return pushMessageRecordMapper.insertMessageRecord(map) > 1;
    }

    @Override
    public void updatePushStatus(PushResult pushResult, String id) {
        if (pushResult == null || pushResult.error != null) {
            pushMessageRecordMapper.updatePushStatus(1, 2, id);
        } else {
            pushMessageRecordMapper.updatePushStatus(1, 1, id);
        }
    }

}
